/*
* Copyright (C) 2021 ~ 2022 Uniontech Technology Co., Ltd.
*
* Author:      zhangbingyi <zhangbingyi@uniontech.com>
*
* Maintainer:  zhangbingyi <zhangbingyi@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "widgets/defendertable.h"
#include "usbstoragesecuritymodel.h"
#include "usbdevicedetailsdelegate.h"

#include <QFrame>
//#include <DBlurEffectWidget>
#include <QLabel>
//#include <DTipLabel>
#include <QCommandLinkButton>

#include <QWidget>
#include <QObject>

using namespace def::widgets;

class USBDeviceDetailsDlg : public QFrame
{
    Q_OBJECT
public:
    explicit USBDeviceDetailsDlg(USBStorageSecurityModel *model, const USBConnectionInfo &info, QWidget *parent = nullptr);
    virtual ~USBDeviceDetailsDlg() override;

private:
    // 初始化界面
    void initUI();
    // 初始化信号连接
    void initConnection();
    // 初始化数据
    void initDate();
    // 初始化设备4个信息布局
    QVBoxLayout *initUSBInfoWidgetLayout();
    // 组合设备信息Item
    QWidget *setLabelItem(const QString &str1, const QString &str2);
    // 初始化中间 tableview 布局
    QHBoxLayout *initTableWidgetLayout();
    // 向设备详情表中添加数据
    void appendDetails(const USBConnectionInfo &info);

protected:
    void closeEvent(QCloseEvent *event) override;

public Q_SLOTS:
    void onRecvUSBDetailsConnList(const USBConnectionInfoList &list); // 接收Dbus发来的 USB设备详情页信息
    void exportDetailsLog(); // 导出设备详情日志
    void updateUIStatus(); // 更新界面启用状态

private:
    USBStorageSecurityModel *m_usbStorageSecurityModel; //数据处理类model
//    DBlurEffectWidget *m_blurEffect;
    QLabel *m_titleLabel;
    DefenderTableHeaderView *m_headerDelegate; // 表头代理类
    QTableView *m_usbdetailsTable;
    QStandardItemModel *m_standardItemModel; // QT表格模型
    USBDeviceDetailsDelegate *m_USBDeviceDetailsDelegate; // 代理
    USBConnectionInfo m_usbInfo;
    QLabel *m_USBPic; // 设备展示图片
    QLabel *m_lbTotal; // 统计数据
    QCommandLinkButton *m_importBtn; // 白名单导入按钮
};
